package com.gton.lpl;

import java.util.Arrays;

/**
 * @description: 随机数
 * @author: GuoTong
 * @createTime: 2021-10-18 21:12
 * @since JDK 1.8 OR 11
 **/
public class RandomByMy {
    //java 参数传递是值传递 Vs 引用传递
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        System.out.println("引用数据类型变量改变前：" + arr + ":" + Arrays.toString(arr));
        changeParam(arr);
        System.out.println("引用数据类型变量改变后：" + arr + ":" + Arrays.toString(arr));
    }

    public static void changeParam(int[] arr) {
        System.out.println("引用数据类型参数传入：" + arr + ":" + Arrays.toString(arr));
        arr[0] = arr[arr.length - 1];
        System.out.println("修改传入形参引用数据类型的值：" + arr + ":" + Arrays.toString(arr));
        arr = new int[]{4, 4, 4, 4, 4};
        System.out.println("修改传入形参引用数据类型的地址：" + arr + ":" + Arrays.toString(arr));
    }
}